<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    // 1- 字面量写法（单例模式）
    const obj = {

    }

    // 2- 工厂模式
    const obj2 = {
        userName:"zhangsan",
        age:12
    }
    const obj3 = {
        userName:"lisi",
        age:18
    }

    function getObj(userName,age){
        return {
            userName,
            age
        }
    }
    const obj4 = getObj("zhangsan",12);
    const obj5 = getObj("lisi",18);

    // 3- 构造函数
    const Box = function(userName,age){
        this.userName = userName;
        this.age = age;
    }
    const obj6 = new Box("zhaoliu",14);

    // 4- Object
    const obj7 = new Object();// new 可以省略
    obj7.userName = "zhangsan";
</script>
</html>